//
//  PersonalVipSectionHeader.m
//  ChatForHot
//
//  Created by wr on 2018/10/12.
//  Copyright © 2018年 FLY. All rights reserved.
//

#import "PersonalVipSectionHeader.h"
#import "PersonalVipViewModel.h"
#import "PersonalCurrentUserVipModel.h"

@interface PersonalVipSectionHeader ()

@property (nonatomic, strong) PersonalVipViewModel *model;
@property (nonatomic, strong) UIImageView *HOTCHATremainImageView;
@property (nonatomic, strong) UILabel *HOTCHATremainTitleLabel;
@property (nonatomic, strong) UILabel *HOTCHATremainDaysLabel;
@property (nonatomic, strong) UIView *HOTCHATlineView;
@end

@implementation PersonalVipSectionHeader

- (instancetype) initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self HOTCHATdidInitialized];
    }
    return self;
}

- (void)HOTCHATdidInitialized {
    self.HOTCHATremainImageView = [[UIImageView alloc] init];
    [self.HOTCHATremainImageView setImage:[UIImage imageNamed:@"p_vip_ic_days"]];
    [self addSubview:self.HOTCHATremainImageView];
    
    self.HOTCHATremainTitleLabel = [[UILabel alloc] init];
    self.HOTCHATremainTitleLabel.font = [UIFont systemFontOfSize:14.0];
    self.HOTCHATremainTitleLabel.textColor = [UIColor colorFromHexString:@"#3D3D3D"];
    self.HOTCHATremainTitleLabel.text = NSLocalizedString(@"personalVIP1", nil);
    [self addSubview:self.HOTCHATremainTitleLabel];
    
    self.HOTCHATremainDaysLabel = [[UILabel alloc] init];
    self.HOTCHATremainDaysLabel.font = [UIFont systemFontOfSize:18];
    self.HOTCHATremainDaysLabel.textColor = [UIColor colorFromHexString:@"111111"];
    [self addSubview:self.HOTCHATremainDaysLabel];
    
    self.HOTCHATlineView = [[UIView alloc] init];
    self.HOTCHATlineView.backgroundColor = [UIColor colorFromHexString:@"111111"];
    [self addSubview:self.HOTCHATlineView];
}

- (void)HOTCHATbindbind:(PersonalVipViewModel *)model {
    _model = model;
    if (model == nil) {
        return;
    }
    PersonalCurrentUserVipModel *cmodel = [model.cuserVipInfoArray objectOrNilAtIndex:0];
    if (cmodel.isWrite) {
        self.HOTCHATremainDaysLabel.text = [NSString stringWithFormat:@"%zi",cmodel.writeDay];
    }else if (cmodel.isDiamond) {
        self.HOTCHATremainDaysLabel.text = [NSString stringWithFormat:@"%zi",cmodel.diamondDay];
    }else if (cmodel.isSupremacy) {
        self.HOTCHATremainDaysLabel.text = [NSString stringWithFormat:@"%zi",cmodel.supremacyDay];
    }else {
        self.HOTCHATremainDaysLabel.text = @"0";
    }
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.HOTCHATremainImageView.size = CGSizeMake(19, 19);
    self.HOTCHATremainImageView.centerY = self.centerY;
    self.HOTCHATremainImageView.left = 15;
    
    self.HOTCHATremainTitleLabel.size = CGSizeMake(105, 21);
    self.HOTCHATremainTitleLabel.left = self.HOTCHATremainImageView.right + 10;
    self.HOTCHATremainTitleLabel.centerY = self.HOTCHATremainImageView.centerY;
    
    self.HOTCHATremainDaysLabel.size = CGSizeMake(105, 21);
    self.HOTCHATremainDaysLabel.left = self.HOTCHATremainTitleLabel.right + 10;
    self.HOTCHATremainDaysLabel.centerY = self.HOTCHATremainTitleLabel.centerY;
    
    self.HOTCHATlineView.size = CGSizeMake(kScreenWidth, PixelOne);
    self.HOTCHATlineView.bottom = self.bottom;
    self.HOTCHATlineView.left = 0;
}
@end
